package com.blockchain.console.servlets.financial.gd;

import java.sql.Timestamp;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blockchain.common.enums.GdState;
import com.blockchain.console.service.financial.GdglManage;
import com.blockchain.console.service.financial.entity.GdglRecord;
import com.blockchain.console.service.financial.query.GdglRecordQuery;
import com.blockchain.console.servlets.financial.AbstractFinancialServlet;
import com.blockchain.framework.http.servlet.annotation.Right;
import com.blockchain.framework.service.ServiceSession;
import com.blockchain.framework.service.query.Paging;
import com.blockchain.framework.service.query.PagingResult;
import com.blockchain.util.parser.IntegerParser;
import com.blockchain.util.parser.TimestampParser;

@Right(id = "C_FINANCIAL_GDGLLIST",isMenu=true, name = "挂单管理")
public class GdYpx extends AbstractFinancialServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void processGet(HttpServletRequest request,
			HttpServletResponse response, ServiceSession serviceSession)
			throws Throwable {
		processPost(request, response, serviceSession);
	}

	@Override
	protected void processPost(final HttpServletRequest request,
			final HttpServletResponse response,
			final ServiceSession serviceSession) throws Throwable {
		GdglManage extraction = serviceSession.getService(GdglManage.class);
		PagingResult<GdglRecord> result = extraction.searchYpx(
				new GdglRecordQuery() {

					@Override
					public int getLsh() {
						return IntegerParser.parse(request.getParameter("lsh"));
					}

					@Override
					public String getYhm() {
						return request.getParameter("yhm");
					}

					@Override
					public String getXm() {
						return request.getParameter("xm");
					}

					@Override
					public Timestamp getStartExtractionTime() {
						return TimestampParser.parse(request
								.getParameter("startExtractonTime"));
					}

					@Override
					public Timestamp getEndExtractionTime() {
						return TimestampParser.parse(request
								.getParameter("endExtractionTime"));
					}

					@Override
					public Timestamp getStartTime() {
						return null;
					}

					@Override
					public Timestamp getEndTime() {
						return null;
					}

					@Override
					public GdState getStatus() {
						return GdState.YPX;
					}
					
				}, new Paging() {
					@Override
					public int getSize() {
						return 10;

					}

					@Override
					public int getCurrentPage() {
						return IntegerParser.parse(request
								.getParameter(PAGING_CURRENT));

					}
				});
		request.setAttribute("result", result);
		forwardView(request, response, getClass());
	}
}
